-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taskgroup decorator #15034
Taskgroup decorator #15034
Conversation
The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*. |
48d7a8f
to
fa9f0e3
Compare
6ece11f
to
def4f1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure the duplicate/reusing TG id behaviour is right yet, and code can be simplified a bit I think.
execution_date = pendulum.parse("20201109") | ||
with DAG(dag_id="example_duplicate_task_group_id", start_date=execution_date, tags=["example"]) as dag: | ||
task_group1() | ||
task_group2() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have expected this to fail: this is three separate task groups, all with the same name.
Calling the same TG more than once is when I would expect the __1
suffix to be added, but having actual duplicate TG ids for different groups I think should be an error case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node_ids = {
'id': None,
'children': [
{
'id': 'task_group1',
'children': [
{'id': 'task_group1.start_task'},
{'id': 'task_group1.task'},
{'id': 'task_group1.task__1'},
],
},
{'id': 'task_group1__1', 'children': [{'id': 'task_group1__1.task1'}]},
{'id': 'task_group1__2', 'children': [{'id': 'task_group1__2.end_task'}]},
],
}
I think this is the correct functionality. With taskgroup decorators people might be importing these from external sources and might therefore not have control over the group_id of that TaskGroup. Automatically adding a suffix can prevent failed DAGs when using these externally created resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, given there's no way to override the name of a TG, true.
Fixed Typo. Added test case of multicall taskgroup Removed reference from docs Removed print Example include in docs Update airflow/utils/task_group.py Co-authored-by: Ash Berlin-Taylor <[email protected]>
Co-authored-by: Ash Berlin-Taylor <[email protected]>
Co-authored-by: Ash Berlin-Taylor <[email protected]>
Co-authored-by: Ash Berlin-Taylor <[email protected]>
Co-authored-by: Ash Berlin-Taylor <[email protected]>
def4f1b
to
2e58768
Compare
Co-authored-by: Ash Berlin-Taylor <[email protected]>
Co-authored-by: Ash Berlin-Taylor <[email protected]>
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
From #13479
Added task_group decorator which can be used to create taskgroup from python callable. Inside python callable tasks can be grouped by calling tasks (python callable ) created with task decorator.
taskgroup decorator takes both optional and keyword argument which are passed to Constructor of TaskGroup class.
TaskGroup can be created with one of following syntax
Following is a simple example demonstrating use of taskgroup decorator grouping multiple tasks.
task_group decorator utilizes existing TaskGroup context manager currently used for creating TaskGroup, which means we can create nested taskgroup by created nested callable. Following is an example demonstrating use of nested taskgroup.
Dedicated test cases for taskgroup decorator is created in file
/tests/utils/test_task_group_decorator.py
Recent changes
closes: #11870
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.